import request from "@/utils/request";
import { AxiosPromise } from "axios";
import {
  ScheduleForm,
  ScheduleOptions,
  SchedulePage,
  ScheduleQuery,
} from "./types";

/**
 * 获取分页列表
 *
 * @param queryParams
 */
export function getSchedulePage(
  queryParams: ScheduleQuery
): AxiosPromise<PageResult<SchedulePage[]>> {
  return request({
    url: "/admin/schedule/index",
    method: "get",
    params: queryParams,
  });
}

export function getSchedule(): AxiosPromise<SchedulePage[]> {
  return request({
    url: "/admin/schedule/getLst",
    method: "get",
  });
}

export function getOptions(): AxiosPromise<ScheduleOptions[]> {
  return request({
    url: "/admin/schedule/getOptions",
    method: "get",
  });
}
/**
 * 获取表单详情
 *
 * @param ids
 */
export function getScheduleForm(ids: number): AxiosPromise<ScheduleForm> {
  return request({
    url: "/admin/schedule/edit",
    method: "get",
    params: {
      ids: ids,
    },
  });
}

/**
 * 添加
 *
 * @param data
 */
export function addSchedule(data: any) {
  return request({
    url: "/admin/schedule/add",
    method: "post",
    data: data,
  });
}

/**
 * 修改
 *
 * @param id
 * @param data
 */
export function updateSchedule(data: ScheduleForm) {
  return request({
    url: "/admin/schedule/edit",
    method: "put",
    data: data,
  });
}

/**
 * 删除
 *
 * @param data
 */
export function deleteSchedule(data: any) {
  return request({
    url: "/admin/schedule/del",
    method: "delete",
    data,
  });
}
